home *** CD-ROM | disk | FTP | other *** search
- /* file: digester2.3.c
- purpose: digest e-mails from info-mac digest into HTML format
- author: Andre' C. van der Ham
- e-mail: A.C.vanderHam@ET.TUDelft.NL
-
- notice: Don't forget to set the path to your scripts directory
-
- for THINK C users:
- project profile:
- segment 1: digester
- MacTraps
- segment 2: ANSI
- unix
-
- project type: size: 200K
- flags: 0080 32-bit compatibility
-
- You had better also delete all the num_args and arg_strings stuff in main.
- So, 'int main( void )'.
-
- */
-
- /* includes */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #ifdef __THINK__
- #include <Files.h>
- #include <console.h>
- #include <StandardFile.h>
- #endif
-
- #define LINELENGTH 80
- #define DRE "http://lcewww.et.tudelft.nl/people/vdham/vdham.html"
- #define PARMS "digester.par"
- #define DIGESTER "Digester 2.3"
- #define DIGWHERE "http://lcewww.et.tudelft.nl/people/vdham/info-mac/"
- #define notify printf
-
- int debug=0;
-
- FILE *outTPrg, *outTMes, *outPrg, *outMes, *inP;
-
- typedef struct Pars
- {
- char adLink[80]; /* link to ad */
- char adImage[80]; /* link to image */
- int adOn; /* boolean if ad feature is on */
-
- char scriptPath[80]; /* path to mail script */
- char imagePath[80]; /* path to images of buttons */
- char sitesFile[20]; /* path to sites file */
- char destPath[80]; /* additional path for destination files */
- char Ftype[10]; /* finder type */
- char Fcreator[10]; /* finder creator */
-
- char DigestName[20]; /* name of the original digest file */
- char nameAll[20]; /* name of the complete HTML digest file */
- char nameTOC[20]; /* name of the toc only file */
- char nameProg[20]; /* name of the programs file (either with or without toc) */
- char nameMess[20]; /* name of the messages file (either with or without toc) */
-
- char BegOfDigest[80]; /* begin of digest text */
- char Volume[80]; /* volume number prefix */
- char Issue[80]; /* issue number prefix */
- char Date[20]; /* date text prefix */
-
- char EndOfDigest[80]; /* end of digest text */
- char BeginOfTopics[80]; /* begin of topics text */
- char EndOfTopics[80]; /* end of topics text */
- char EndOfMessage[80]; /* end of message text */
-
- char RootPath[20]; /* begin of root directory of mirror */
- char BegOfFile[40]; /* begin of file path */
- char EndOfFile[20]; /* end of file path */
-
- int Type; /* type of digest */
- int Buttons; /* buttons on/off */
- int Mail; /* mail button on/off */
- int Files; /* archive files link on/off */
- int URLs; /* URL link on/off */
- int MURLs; /* mail URLs on/off */
-
- char *sites; /* pointer to array of strings of mirror sites */
- int nSites; /* number of sites in array */
-
- char mFrom[20]; /* e-mail from */
- char mTo[20]; /* to */
- char mDate[20]; /* date */
- char mSubject[20]; /* subject */
- } *ParsP;
-
-
- typedef struct Vars
- {
- char whichFile[512];
- int VolNum;
- int Issue;
- int itemCount;
- char header[100]; /* header of digest */
-
- char nameAll[20]; /* name of the complete digest file */
- char nameTOC[20]; /* name of the toc only file */
- char nameProg[20]; /* name of the programs file (either with or without toc) */
- char nameMess[20]; /* name of the messages file (either with or without toc) */
-
- } *VarsP;
-
-
- #ifdef __THINK__
-
- /**********************************
-
- Mac specific file get function
-
- */
-
- int GetName( char *name )
- {
- SFReply theReply;
- Point where;
- SFTypeList typeList;
-
- typeList[0]='TEXT'; /* file type to search for */
- where.h=20; where.v=90; /* SF dialog window position */
-
- SFGetFile(where,0,0L,1,typeList,NULL,&theReply);
-
- if ( theReply.good == TRUE )
- {
- strncpy( name, (char *)(theReply.fName+1), theReply.fName[0] );
- name[theReply.fName[0]]=0;
- return(1);
- }
- else
- return(0);
- }
-
- #endif
-
- /**********************************
-
- Find the DIGEST header and fill-in the volume and issue numbers
- also the header is copied for future use
-
- */
-
- int findHeader( ParsP p, VarsP v, char *line, int parse )
- {
- char *cptr;
- int found=0;
-
- /* init header vars */
-
- if(parse)
- {
- v->VolNum=0;
- v->Issue=0;
- }
-
- /* while there is still a line to read find header */
-
- do {
- if( feof( inP ) )
- {
- notify("End of file reached.\n");
- notify("Could not find Begin of Digest (BOD) tag.\n");
- notify("Closing file ...\n");
- return(0);
- }
-
- /* check if the line is not empty */
-
- if( fgets( line, 256, inP ) != NULL )
- {
- /* check for the begin of digest string */
-
- if( strncmp( line, p->BegOfDigest, strlen(p->BegOfDigest) ) == 0 )
- {
- notify("Found %s\n", p->BegOfDigest);
- notify(line);
-
- strcpy( v->header, line ); /* make a copy for use as heading */
-
- found = 1;
-
- /* extract volume number */
-
- if( parse )
- {
- if( p->Volume!=NULL )
- {
- if( strlen(p->Volume)>0 )
- {
- cptr = (char *)strstr( line, p->Volume );
- if( cptr==NULL )
- {
- notify("Can't find volume number\n");
- notify("Please specify Volume number: ");
- scanf("%d", &(v->VolNum));
- }
- else
- v->VolNum = atoi( cptr+strlen(p->Volume) );
- }
- }
-
- /* extract issue number */
-
- if( p->Issue!=NULL )
- {
- if( strlen(p->Issue)>0 )
- {
- cptr = (char *)strstr( line, p->Issue );
- if( cptr==NULL )
- {
- notify("Can't find issue number\n");
- notify("Please specify Issue number: ");
- scanf("%d", &(v->Issue));
- }
- else
- v->Issue = atoi( cptr+strlen(p->Issue) );
- }
- else
- {
- notify("Please specify Issue number: ");
- scanf("%d", &(v->Issue));
- }
- }
- }
- }
- }
- } while( !found );
-
- return(1);
- }
-
- void GetDestName( char *format, VarsP v, char *name, char *path, char *comment )
- {
- char dummy[200];
-
- if( (v->Issue!=0) && (v->VolNum!=0) )
- {
- sprintf(name, format, v->Issue, v->VolNum );
- }
- else if( (v->Issue!=0 ) )
- {
- sprintf(name, format, v->Issue );
- }
- else
- {
- notify( comment );
- fgets(name,38,stdin);
-
- if( strlen(name)<1 )
- {
- notify("Illegal file name!\n");
- strcpy( name, "digest.html");
- notify("Using default ");
- }
- }
-
- strcat(path, name);
- notify("name = '%s'\n", path);
- }
-
- #ifdef __THINK__
-
- void SetupFinderInfo( char *name, OSType type, OSType creator, char *path )
- {
- char fileN[200];
- Str255 fileName;
- FInfo fndrInfo;
-
- strcpy( fileN, path );
- strcat( fileN, name );
-
- notify("Setting up finder info for '%s'.\n", fileN);
-
- strncpy( (char *)fileName+1, fileN, strlen(fileN) );
-
- fileName[0] = strlen(fileN);
-
- if( GetFInfo(fileName,0,&fndrInfo)==0 )
- {
- fndrInfo.fdType = type;
- fndrInfo.fdCreator = creator;
- if( SetFInfo(fileName, 0, &fndrInfo)!=0 )
- {
- notify("OS error setting finder info.\n");
- }
- }
- else
- {
- notify("Couldn't set type creator due to OS error.\n");
- }
- }
-
- void SetUpAllFinderInfo( ParsP p, VarsP v )
- {
- OSType type, creator;
- int i;
- OSType k, test;
-
-
- if( (strlen(p->Ftype)<4) || (strlen(p->Fcreator)<4) )
- {
- notify("Illegal type (FTYPE) and creator (FCREAT) specified.\n");
- notify("Type and creator parameters should be 4 characters long.\n");
- notify("Please, check your parameters file.\n");
- return;
- }
-
- k=1;
- type=0;
- creator=0;
-
- test=255;
-
- if( (char)test!=255 ) /* if little endian */
- {
- notify("You have a Little Endian processor. Great, so what! Just checking.\n");
-
- for(i=0; i<4; i++)
- {
- type+=(OSType)(p->Ftype[3-i])*k;
- creator+=(OSType)(p->Fcreator[3-i])*k;
- if(i<3) k *= 256;
- }
- }
- else
- {
- notify("You have a Big Endian processor. Great, so what! Just checking.\n");
-
- for(i=0; i<4; i++)
- {
- type+=(OSType)(p->Ftype[i])*k;
- creator+=(OSType)(p->Fcreator[i])*k;
- if(i<3) k *= 256;
- }
- }
-
- notify("Type: '%s', Creator '%s'.\n", p->Ftype, p->Fcreator);
-
- switch( p->Type )
- {
- case 1: /* type 1: the entire digest in 1 file */
-
- SetupFinderInfo( v->nameAll, type, creator, p->destPath );
- break;
-
- case 2: /* type 2: topics, programs and messages as separate files */
-
- SetupFinderInfo( v->nameTOC, type, creator, p->destPath );
- if( p->Files )
- {
- SetupFinderInfo( v->nameProg, type, creator, p->destPath );
- }
- SetupFinderInfo( v->nameMess, type, creator, p->destPath );
- break;
-
- case 3: /* type 3: toc + progs, toc + mes */
-
- /* toc + progs files */
-
- if( p->Files )
- {
- SetupFinderInfo( v->nameProg, type, creator, p->destPath );
- }
-
- SetupFinderInfo( v->nameMess, type, creator, p->destPath );
- break;
- }
-
- }
-
- #endif
-
-
-
- int SetUpFiles( ParsP p, VarsP v )
- {
- char name[200];
-
- /* set-up output files */
-
- switch( p->Type )
- {
- case 1: /* type 1: the entire digest in 1 file */
-
- notify("Type 1:\n");
-
- strcpy( name, p->destPath );
- GetDestName( p->nameAll, v, v->nameAll, name,
- "Please specify destination file name for entire digest: " );
-
- if( (outTMes = fopen( name,"w")) == NULL )
- {
- notify( "Can't open '%s'\n", name );
- return(0);
- }
-
- if(debug)
- notify( "outTMes = %x\n", outTMes );
-
- outTPrg = NULL;
- outMes = NULL;
- outPrg = NULL;
- break;
-
- case 2: /* type 2: topics, programs and messages as separate files */
-
- notify("Type 2:\n");
-
- strcpy( name, p->destPath );
- GetDestName( p->nameTOC, v, v->nameTOC, name,
- "Please specify destination file name for topics: " );
-
- if( (outTMes = fopen( name,"w")) == NULL )
- {
- notify("Can't open '%s'\n", name );
- return(0);
- }
-
- outTPrg = NULL;
-
- if( p->Files )
- {
- strcpy( name, p->destPath );
- GetDestName( p->nameProg, v, v->nameProg, name,
- "Please specify destination file name for programs: " );
-
- if( (outPrg = fopen( name,"w")) == NULL )
- {
- notify("Can't open '%s'\n", name );
- return(0);
- }
-
- }
-
- strcpy( name, p->destPath );
- GetDestName( p->nameMess, v, v->nameMess, name,
- "Please specify destination file name for messages: " );
-
- if( (outMes = fopen( name,"w")) == NULL )
- {
- notify("Can't open '%s'\n", name );
- return(0);
- }
-
- break;
-
- case 3: /* type 3: toc + progs, toc + mes */
-
- /* toc + progs files */
-
- if( p->Files )
- {
- strcpy( name, p->destPath );
- GetDestName( p->nameProg, v, v->nameProg, name,
- "Please specify destination file name for programs: " );
-
- if( (outTPrg = fopen( name,"w")) == NULL )
- {
- notify("Can't open '%s'\n", name );
- return(0);
- }
- }
-
- outPrg = NULL;
-
- /* toc + messages files */
-
- strcpy( name, p->destPath );
- GetDestName( p->nameMess, v, v->nameMess, name,
- "Please specify destination file name for messages: " );
-
- if( (outTMes = fopen( name,"w")) == NULL )
- {
- notify("Can't open '%s'\n", name );
- return(0);
- }
-
- outMes = NULL;
- break;
-
- default:
- notify( "Type of digest has not been specified, please check %s file.\n", PARMS);
- return(0);
- break;
- }
-
- return(1);
- }
-
-
- void SetUpTitle( ParsP p, VarsP v, FILE *out, char *Message )
- {
- if( out != NULL )
- {
- fprintf(out,"<TITLE>Volume %d : Issue %d</TITLE>\n", v->VolNum, v->Issue);
- fprintf(out,"<pre>\n\n");
- fprintf(out,"<a href=index.html#issue%d-%d><img src=%sdigester.gif alt=Index></a> %s",
- v->Issue+1, v->VolNum, p->imagePath, Message);
-
- fprintf(out,"</pre>\n\n");
- fprintf(out,"<hr>\n\n");
-
- /* include ad! */
-
- if( p->adOn==1 )
- {
- fputs("<BR><CENTER>",out);
- fputs("<TABLE BORDER=5><TR><TD>", out);
- fprintf(out, "<A HREF=%s><IMG ALT=CLICK_ME BORDER=1 SRC=%s></A>\n",
- p->adLink, p->adImage);
- fputs("</TD></TR></TABLE>", out);
- fputs("</CENTER><BR>", out);
- }
- }
- }
-
- char *findALink( char *line )
- {
- char *cptr;
-
- if( (cptr=strstr(line, "http://"))!=NULL ) return(cptr);
- if( (cptr=strstr(line, "ftp://"))!=NULL ) return(cptr);
- if( (cptr=strstr(line, "mailto:"))!=NULL ) return(cptr);
- if( (cptr=strstr(line, "gopher://"))!=NULL ) return(cptr);
-
- return(NULL);
- }
-
- void linkLine( char *line )
- {
- char *cptr, *bptr, tempLine[512], resultLine[512];
- int found;
-
- cptr = line;
- resultLine[0]=0;
-
- do {
- found=0;
- bptr=cptr;
-
- if( (cptr=findALink(bptr))!=NULL )
- {
- found=1;
- if(debug) puts("found URL");
- strncpy(tempLine, bptr, cptr-bptr); /* copy preceeding stuff */
- tempLine[cptr-bptr]=0;
- strcat(resultLine, tempLine);
- bptr=cptr;
- while( (*cptr!=0) && (*cptr!='\n') /* find delimiter */
- && ( (*cptr=='.') || (*cptr=='~') || (*cptr=='/') || (*cptr=='@')
- || (*cptr==':') || (*cptr=='-') || (*cptr=='+') || (*cptr=='_')
- || ((*cptr>='a') && (*cptr<='z'))
- || ((*cptr>='A') && (*cptr<='Z'))
- || ((*cptr>='0') && (*cptr<='9'))
- || (*cptr=='%')
- )
- ) cptr++;
- strncpy(tempLine, bptr, cptr-bptr); /* copy link */
- tempLine[cptr-bptr]=0;
- strcat(resultLine, "<a href=");
- strcat(resultLine, tempLine);
- strcat(resultLine, ">");
- strcat(resultLine, tempLine);
- strcat(resultLine, "</a>");
- }
- } while( found );
-
- if( bptr==line ) return; /* nothing happened */
- strcat( resultLine, bptr ); /* copy rest of the line */
- strcpy( line, resultLine ); /* copy it back */
- }
-
-
- void filterEntities( char *line )
- {
- char tempLine[512];
- int l, i;
-
- tempLine[0]=0;
- l = 0;
- for(i=0; i<strlen(line); i++ )
- {
- if( line[i]=='<' )
- {
- tempLine[l++] = '&';
- tempLine[l++] = 'l';
- tempLine[l++] = 't';
- tempLine[l++] = ';';
- }
- else
- if( line[i]=='>' )
- {
- tempLine[l++] = '&';
- tempLine[l++] = 'g';
- tempLine[l++] = 't';
- tempLine[l++] = ';';
- }
- else
- if( line[i]=='"' )
- {
- tempLine[l++] = '&';
- tempLine[l++] = 'q';
- tempLine[l++] = 'u';
- tempLine[l++] = 'o';
- tempLine[l++] = 't';
- tempLine[l++] = ';';
- }
- else
- if( line[i]=='&' )
- {
- tempLine[l++] = '&';
- tempLine[l++] = 'a';
- tempLine[l++] = 'm';
- tempLine[l++] = 'p';
- tempLine[l++] = ';';
- }
- else
- {
- tempLine[l++] = line[i];
- tempLine[l] = 0;
- }
- }
- strcpy( line, tempLine );
- }
-
-
- int SkipTOC( ParsP p, VarsP v, int addInfo )
- {
- int found;
- char line[256];
-
- found = 0;
-
- if( strlen(p->BeginOfTopics)<1 )
- {
- /* don't bother with TOC */
- if( strlen(p->EndOfTopics)>0 )
- {
- do {
- if( fgets( line, 256, inP ) != NULL )
- if(strstr( line, p->EndOfTopics ) != NULL)
- {
- if( debug )
- notify( "Found end of Topics\n");
-
- return(1);
- }
- } while( !feof(inP ) );
-
- notify("Couldn't find the begining of the messages.\n");
- notify("Please, check the %s file EOT tag.\n", PARMS);
-
- return(0);
- }
-
- notify("No BOT or EOT tag in %s\n", PARMS);
-
- return(1);
- }
-
- do {
- if( fgets( line, 256, inP ) != NULL )
- {
- if( strstr( line, p->BeginOfTopics ) != NULL )
- {
- if( debug )
- notify( "Found begin of Topics\n");
-
- found = 1;
- }
-
- if(strstr( line, p->EndOfTopics ) != NULL)
- {
- if( debug )
- notify( "Found end of Topics\n");
-
- return(1);
- }
- }
- else
- {
- return(0);
- }
- } while( !found );
-
- fgets( line, 256, inP ); /* get empty line */
-
- /* skip TOC */
-
- do{
- fgets( line, 256, inP );
- }while( (strlen(line)>1)
- && !feof(inP)
- && (strstr( line, p->EndOfTopics ) == NULL)
- );
-
- if(debug)
- notify("TOC skipped\n");
-
- if( strstr( line, p->EndOfTopics ) != NULL ) return(1);
-
- /* Now copy all lines to message files */
-
- if( outTMes!=NULL && addInfo==1 )
- fputs( "<HR><P><PRE>", outTMes );
-
- if( outTPrg!=NULL && addInfo==1 )
- fputs( "<HR><P><PRE>", outTPrg );
-
- do
- {
- fgets( line, 256, inP );
- filterEntities(line);
- if( p->URLs ) linkLine( line );
-
- if( outTMes!=NULL && addInfo==1 )
- fputs( line, outTMes );
-
- if( outTPrg!=NULL && addInfo==1 )
- fputs( line, outTPrg );
- }
- while( (strstr( line, p->EndOfTopics ) == NULL ) && !feof(inP) );
-
- if( outTMes!=NULL && addInfo==1 )
- fputs( "</PRE>", outTMes );
-
- if( outTPrg!=NULL && addInfo==1 )
- fputs( "</PRE>", outTPrg );
-
- if( feof(inP) )
- {
- notify( "Cannot find end of Topics phrase ... aborting\n");
- return(0);
- }
-
- if(debug)
- notify("Found end of TOC\n");
-
- return(1);
- }
-
- void DoFTPMessage( ParsP p, FILE *outP )
- {
- int i;
- char name[20];
-
- fputs("\n<HR>\n<CENTER>\n", outP);
- fputs("<H4>Direct FTP to mirror site</H4>", outP);
- fputs("</CENTER>\n", outP);
-
- fprintf(outP, "Make FTP connection with: ");
- strcpy( name, "/info-mac/");
-
- for(i=0; i<p->nSites; i++)
- {
- fputs( "", outP );
- fprintf( outP, p->sites+i*LINELENGTH, name);
- }
-
- fputs( ".\n<P><HR><P>\n", outP );
- }
-
- int MakeTOC(ParsP p, VarsP v, char *line)
- {
- int msgItem;
- char subject[80];
- char topic[200];
- int found;
-
- msgItem = 0;
-
- if( outTMes==NULL )
- {
- notify( "Error in making TOC, Message output file is not open (pointer NULL)\n\n");
- return(0);
- }
-
- if( outTPrg != NULL )
- {
- fputs( "<HR><CENTER>", outTPrg );
- fputs( "<HR><CENTER>", outTMes );
- fputs( "<H3>Programs: Table of Contents</H3>", outTPrg );
- fputs( "<H3>Messages: Table of Contents</H3>", outTMes );
- fputs( "</CENTER><HR>", outTPrg );
- fputs( "</CENTER><HR>", outTMes );
- fputs( "<UL>", outTPrg );
- fputs( "<UL>", outTMes );
- }
- else
- {
- fputs( "<HR><CENTER>", outTMes );
- fputs( "<H3>Table of Contents</H3>", outTMes );
- fputs( "</CENTER><HR>", outTMes );
- fputs( "<UL>", outTMes );
- }
-
- do{
- msgItem++;
-
- strcpy( subject, "" ); /* default */
- found=0;
-
- fgets( line, 256, inP );
- while( (strncmp( line, p->EndOfMessage, strlen(p->EndOfMessage) )!=0) &&
- (strstr( line, p->BegOfDigest ) == NULL) &&
- (strstr( line, p->EndOfDigest ) == NULL) &&
- !feof(inP) )
- {
- filterEntities( line );
-
- if( (strncmp( line, p->mFrom, strlen( p->mFrom ) )==0)
- && !found )
- {
- strcpy( subject, "(NO SUBJECT)" ); /* default */
- v->whichFile[msgItem]='m';
- }
-
- /* find subject */
- if( (strncmp( line, p->mSubject, strlen( p->mSubject ) )==0)
- && !found )
- {
- strncpy( subject, line+strlen( p->mSubject ), 78);
- subject[79]=0;
- found=1;
- }
-
- if( p->Files )
- if( strstr( line, p->BegOfFile ) != NULL )
- {
- if(debug)
- notify("Found file link for item %d!\n", msgItem);
-
- v->whichFile[msgItem]='p';
- }
-
- fgets( line, 256, inP );
- } /* while not end of message */
-
- /* end of message, write TOC entry */
-
- if( subject[0]!=0 ) /* check if there is a subject anyway */
- {
- /* set correct icon */
- if( v->whichFile[msgItem] == 'p' )
- sprintf(topic, "<IMG SRC=%sprog_topic.gif ALT=Program> ", p->imagePath);
- else
- sprintf(topic, "<IMG SRC=%smsg_topic.gif ALT=Message> ", p->imagePath);
-
- if( !p->Buttons )
- strcpy( topic, "<LI> " );
-
- switch( p->Type )
- {
- case 1:
- fprintf(outTMes, "%s<a name=toc%d> </a><a href=#item%d>%s</a>\n",
- topic, msgItem, msgItem, subject);
-
- if( p->Buttons )
- fputs( "<BR>\n", outTMes );
- break;
-
- case 2:
- if( v->whichFile[msgItem]=='m' )
- fprintf(outTMes, "%s<a name=toc%d> </a><a href=%s#item%d>%s</a>\n",
- topic, msgItem, v->nameMess, msgItem, subject);
- else
- fprintf(outTMes, "%s<a name=toc%d> </a><a href=%s#item%d>%s</a>\n",
- topic, msgItem, v->nameProg, msgItem, subject);
-
- if( p->Buttons )
- fputs( "<BR>\n", outTMes );
- break;
-
- case 3:
- if( v->whichFile[msgItem]=='m' )
- {
- fprintf(outTMes, "%s<a name=toc%d> </a><a href=#item%d>%s</a>\n",
- topic, msgItem, msgItem, subject);
-
- if( p->Buttons )
- fputs( "<BR>\n", outTMes );
- }
- else
- {
- fprintf(outTPrg, "%s<a name=toc%d> </a><a href=#item%d>%s</a>\n",
- topic, msgItem, msgItem, subject);
-
- if( p->Buttons )
- fputs( "<BR>\n", outTPrg );
- }
-
-
- break;
-
- default:
- return(0); /* error occured: illegal type specified */
- break;
-
- }
- }
-
- }while( (strncmp( line, p->BegOfDigest, strlen(p->BegOfDigest) ) != 0)
- && (strstr( line, p->EndOfDigest ) == NULL)
- && !feof( inP ) );
-
- if( p->Type==3 ) /* make link between program and Q&A files */
- {
- if( !p->Buttons )
- {
- fprintf( outTMes, "<LI> " );
- fprintf( outTPrg, "<LI> " );
- }
- else
- {
- fprintf( outTMes, "<IMG SRC=%sprog_topic.gif ALT=Program> ", p->imagePath);
- fprintf( outTPrg, "<IMG SRC=%smsg_topic.gif ALT=Message> ", p->imagePath);
-
- }
- fprintf( outTMes, "<a href=%s>[*] PROGRAMS TABLE OF CONTENTS</a><BR>\n", v->nameProg );
- fprintf( outTPrg, "<a href=%s>MESSAGES TABLE OF CONTENTS</a><BR>\n", v->nameMess );
-
- }
-
- if( outTMes!=NULL ) fputs( "</UL>\n<P>\n", outTMes );
- if( outTPrg!=NULL ) fputs( "</UL>\n<P>\n", outTPrg );
-
-
- /* write intro */
-
- if(p->Files)
- {
- switch( p->Type )
- {
- case 1:
- DoFTPMessage( p, outTMes );
- break;
-
- case 2:
- DoFTPMessage( p, outTMes );
- break;
-
- case 3:
- DoFTPMessage( p, outTPrg );
- break;
- }
- }
- else
- {
- if( outTMes!=NULL)
- fputs( ".\n<P><HR><P>\n", outTMes );
- }
-
- return(1);
- }
-
- int IsEmailChar( char c )
- {
- if( (c>='a') && (c<='z') ) return(1);
- if( (c>='A') && (c<='Z') ) return(1);
- if( (c>='0') && (c<='9') ) return(1);
- if( c=='.' ) return(1);
- if( c=='_' ) return(1);
- if( c=='-' ) return(1);
- if( c=='%' ) return(1);
- return(0);
- }
-
- int FetchAddress( char *cptr, char *address )
- {
- char *begin, *end;
-
- if( (begin=strstr(cptr,"@"))==NULL )
- {
- address[0]=0; /* didn't find valid address */
- return(0);
- }
-
- begin--;
-
- /* find beginning of e-mail address */
- while((begin>=cptr) && IsEmailChar(*begin)) begin--;
- /* move one forward to the beginning of the address */
- begin++;
-
- strcpy( address, begin );
-
- /* find end of address */
- if( (end=strstr(address, "@"))==NULL )
- {
- /* this should never happen but just in case */
- address[0]=0;
- return(0);
- }
- end++;
- while( (*end!=0) && IsEmailChar(*end) ) end++;
- /* terminate the address string */
- *end=0;
-
- return(1); /* okay! */
- }
-
- int DoMessages(ParsP p, VarsP v, char *line)
- {
- int msgItem;
- char topic[200];
- char next[200];
- char prev[200];
- char toc[200];
- char post[200];
- char index[200];
- char address[256];
- FILE *outP;
- char name[80], *bptr, *eptr;
- int i, pre;
- char filteredLine[256];
-
- if( p->Buttons )
- {
- sprintf( next, "<img src=%snext.gif alt=Next>", p->imagePath );
- sprintf( prev, "<img src=%sprev.gif alt=Previous>", p->imagePath);
- sprintf( toc, "<img src=%stoc.gif alt=TOC>", p->imagePath);
- sprintf( post, "<img src=%spost.gif alt=MakeReply>", p->imagePath);
- sprintf( index, "<img src=%sdigester.gif alt=Index>", p->imagePath);
- }
- else
- {
- strcpy( next, "Next" );
- strcpy( prev, "Previous" );
- strcpy( toc, "Table of Contents" );
- strcpy( post, "Select Message for Posting" );
- strcpy( index, "Back to INDEX" );
- }
-
- msgItem = 0;
-
- /* do messages */
-
- do{
- msgItem++;
-
- /* choose destination file */
-
- switch( p->Type )
- {
- case 1:
- outP = outTMes;
- break;
-
- case 2:
- if( (v->whichFile[msgItem]=='m') || (outPrg==NULL) )
- outP = outMes;
- else
- outP = outPrg;
- break;
-
- case 3:
- if( (v->whichFile[msgItem]=='m') || (outTPrg==NULL) )
- outP = outTMes;
- else
- outP = outTPrg;
- break;
- }
-
- if( outP == NULL )
- {
- notify("Output file not open!!\n");
- return(0);
- }
-
- /* label the thing */
- fprintf( outP, "<a name=item%d> </a> ", msgItem);
-
- /* write navigation panel */
- if( v->whichFile[msgItem]!='0' )
- switch( p->Type )
- {
- case 1:
- fprintf( outP, "<a href=#item%d>%s</a> ", msgItem+1, next);
- if( msgItem>1) fprintf( outP, "<a href=#item%d>%s</a> ", msgItem-1, prev );
- fprintf( outP, "<a href=#toc%d>%s</a> ", msgItem, toc);
- if(p->Mail) fprintf( outP, "<a href=%spost-send?%d,%s>%s</a> ",
- p->scriptPath, msgItem, v->nameAll, post);
- break;
-
- case 2:
- if(v->whichFile[msgItem+1]!='0')
- {
- if( v->whichFile[msgItem+1]!=v->whichFile[msgItem])
- {
- if( v->whichFile[msgItem+1]=='m' )
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameMess, msgItem+1, next);
- else
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameProg, msgItem+1, next);
- }
- else
- fprintf( outP, "<a href=#item%d>%s</a> ", msgItem+1, next);
- }
-
- if( msgItem>1 && (v->whichFile[msgItem-1]!='0') )
- {
- if( v->whichFile[msgItem-1]!=v->whichFile[msgItem] )
- {
- if( v->whichFile[msgItem-1]=='m' )
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameMess, msgItem-1, prev);
- else
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameProg, msgItem-1, prev);
- }
- else
- fprintf( outP, "<a href=#item%d>%s</a> ", msgItem-1, prev);
- }
-
- fprintf( outP, "<a href=%s#toc%d>%s</a> ", v->nameTOC, msgItem, toc);
-
- if( p->Mail )
- if( v->whichFile[msgItem]=='m' )
- fprintf( outP, "<a href=%spost-send?%d,%s>%s</a> ",
- p->scriptPath, msgItem, v->nameMess, post);
- else
- fprintf( outP, "<a href=%spost-send?%d,%s>%s</a> ",
- p->scriptPath, msgItem, v->nameProg, post);
-
- break;
-
- case 3:
- if(v->whichFile[msgItem+1]!='0')
- {
- if(v->whichFile[msgItem+1]!=v->whichFile[msgItem] )
- {
- if( v->whichFile[msgItem+1]=='m' )
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameMess, msgItem+1, next);
- else
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameProg, msgItem+1, next);
- }
- else
- fprintf( outP, "<a href=#item%d>%s</a> ", msgItem+1, next);
- }
-
- if( (msgItem>1) && (v->whichFile[msgItem-1]!='0') )
- {
- if( v->whichFile[msgItem-1]!=v->whichFile[msgItem] )
- {
- if( v->whichFile[msgItem-1]=='m' )
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameMess, msgItem-1, prev);
- else
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameProg, msgItem-1, prev);
- }
- else
- fprintf( outP, "<a href=#item%d>%s</a> ", msgItem-1, prev);
- }
-
- fprintf( outP, "<a href=#toc%d>%s</a> ", msgItem, toc);
-
- if( p->Mail )
- if( v->whichFile[msgItem]=='m' )
- fprintf( outP, "<a href=%spost-send?%d,%s>%s</a> ",
- p->scriptPath, msgItem, v->nameMess, post);
- else
- fprintf( outP, "<a href=%spost-send?%d,%s>%s</a> ",
- p->scriptPath, msgItem, v->nameProg, post);
-
- break;
- }
-
- if( v->whichFile[msgItem]!='0' )
- fprintf( outP, "<a href=index.html#issue%d-%d>%s</a>\n\n",
- v->Issue+1, v->VolNum, index);
-
- /* end of navigation bar, now do the message */
-
- fputs( "\n<PRE>", outP);
- pre=1;
-
- fgets( line, 256, inP );
- while( (strncmp( line, p->EndOfMessage, strlen(p->EndOfMessage) )!=0) &&
- (strstr( line, p->BegOfDigest ) == NULL) &&
- (strstr( line, p->EndOfDigest ) == NULL) &&
- !feof(inP) )
- {
-
- if( v->whichFile[msgItem]!='0' )
- {
- strcpy( filteredLine, line );
- filterEntities( filteredLine );
- if( p->URLs ) linkLine( filteredLine );
-
- /* find Subject, Date or From */
- if( (strncmp( line, p->mSubject, strlen( p->mSubject ) )==0) ||
- (strncmp( line, p->mDate, strlen( p->mDate ) )==0) ||
- (strncmp( line, p->mFrom, strlen( p->mFrom ) )==0) ||
- (strncmp( line, p->mTo, strlen( p->mTo ) )==0)
- )
- {
- if( pre ) fprintf( outP, "</PRE>");
- pre=0;
- if( (strncmp( line, p->mFrom, strlen( p->mFrom ) )==0) && p->MURLs )
- {
- if( FetchAddress( line+strlen( p->mFrom ), address ) )
- {
- fprintf( outP, "<a href=mailto:%s>%s</a><BR>\n",
- address, filteredLine );
- }
- else
- {
- fprintf( outP, "%s<BR>\n", filteredLine );
- }
-
- }
- else if( (strncmp( line, p->mTo, strlen( p->mTo ) )==0) && p->MURLs )
- {
- if( FetchAddress( line+strlen( p->mTo ), address ) )
- {
- fprintf( outP, "%s<a href=mailto:%s>%s</a><BR>\n",
- address, filteredLine );
- }
- else
- {
- fprintf( outP, "%s<BR>\n", filteredLine );
- }
-
- }
- else
- {
- fprintf( outP, "%s\n<BR>\n", filteredLine);
- }
- }
- else
- {
- if( !pre ) fprintf( outP, "<PRE>");
- pre=1;
-
- fputs(filteredLine, outP);
-
- /* check for begin of file */
-
- if( (strstr( line, p->BegOfFile ) != NULL) && p->Files )
- {
- if(debug)
- notify("Found file link for item %d!\n", msgItem);
-
- bptr=strstr( line, p->RootPath );
- eptr=strstr( line, p->EndOfFile );
-
- if( bptr!=NULL && eptr!=NULL )
- {
- strncpy(name, bptr, eptr-bptr);
- name[eptr-bptr]=0;
-
- fprintf( outP, "\n</pre>\nFetch from " );
-
-
- for(i=0; i<p->nSites; i++)
- {
- fprintf( outP, "\n");
- fprintf( outP, p->sites+i*LINELENGTH, name);
- }
-
- fprintf( outP, ".\n<pre>\n" );
- }
- else
- {
- notify("Failed to make link, sorry :(\n");
- }
- }
- }
- }
- fgets( line, 256, inP );
- } /* while not end of message */
-
- fputs("</PRE>\n<HR>", outP );
-
- } while( (strncmp( line, p->BegOfDigest, strlen(p->BegOfDigest) ) != 0)
- && (strstr( line, p->EndOfDigest ) == NULL)
- && !feof( inP )
- );
-
- /* write last navigation panel */
-
- msgItem++;
-
- /* label the thing */
- fprintf( outP, "<a name=item%d> </a> ", msgItem);
-
- if( debug )
- notify( "Doing Message %d ...\n", msgItem );
-
- switch( p->Type )
- {
- case 1:
- if( msgItem>1) fprintf( outP, "<a href=#item%d>%s</a> ", msgItem-1, prev);
- fprintf( outP, "<a href=#toc1>%s</a> ", toc);
- break;
-
- case 2:
- fprintf( outP, "<a href=%s#item%d>%s</a> ",
- v->nameMess, msgItem-1, prev);
-
- fprintf( outP, "<a href=%s#toc1>%s</a> ", v->nameMess, toc);
- break;
-
- case 3:
- fprintf( outP, "<a href=#item%d>%s</a> ", msgItem-1, prev);
- fprintf( outP, "<a href=#toc1>%s</a> ", toc);
- break;
- }
-
- fprintf( outP, "<a href=index.html#issue%d-%d>%s</a>\n\n",
- v->Issue+1, v->VolNum, index);
-
- notify( "Messages done.\n");
-
- if( (strncmp( line, p->BegOfDigest, strlen(p->BegOfDigest) ) == 0) )
- {
- notify("Found new begin of digest...\n");
- notify("Please, only use one digest per file.\n");
- notify("This version of DIGESTER does not work with multiple digests files.\n");
- }
-
-
- return(1);
- }
-
- #define MAIL "A.C.vanderHam@ET.TUDelft.NL"
-
- void WriteTrailer( FILE *outP )
- {
-
- fputs("<p><hr><p>\n", outP);
- fprintf( outP,"HTML file created by <a href=%sAboutDigester.html>%s</a><p>\n"
- , DIGWHERE, DIGESTER);
- fprintf( outP, "The Home of the HyperDigest is at: <a href=%sindex.html>%sindex.html</a>.<p>\n"
- , DIGWHERE, DIGWHERE );
- fprintf(outP,"Digester developed by: <a href=%s>André C. van der Ham</a><p>\n", DRE);
- fputs("<address>\n", outP);
- fprintf( outP, "Send bug reports, questions, etc. to: <A HREF=MAILTO:%s>%s</A><p>\n", MAIL, MAIL);
- fputs("</address>\n", outP);
- }
-
-
- /***************************************
-
- Parse one digest at a time
- returns 1 if there is still data left after the end-of-digest phrase
-
- */
-
- void ParseOne( ParsP p, char *digestName )
- {
- char line[512];
- char name[256];
- int i;
- struct Vars v;
-
- for(i=0; i<512; i++) /* init destination of all messages to nowhere */
- v.whichFile[i]='0';
-
- /* initialize all file pointers */
-
- outTPrg = NULL;
- outTMes = NULL;
- outPrg = NULL;
- outMes = NULL;
-
- /* B E G I N O F P A S S 1 */
-
- notify("PASS1: '%s'...\n", digestName);
-
- if( (inP = fopen( digestName, "r" )) == NULL )
- {
- notify("Cannot open '%s'\n", digestName);
- notify("Please make sure '%s' is in the same folder as Digester.\n", digestName);
- return;
- }
-
- notify("Parsing...\n");
-
- if( findHeader( p, &v, line, 1 )==0 ) /* set-up header */
- return;
-
- if(debug)
- notify("Title found\n");
-
- if( SetUpFiles( p, &v )==0 ) /* set-up output files */
- {
- if( outTPrg!=NULL ) fclose( outTPrg );
- if( outTMes!=NULL ) fclose( outTMes );
- if( outPrg!=NULL ) fclose( outPrg );
- if( outMes!=NULL ) fclose( outMes );
- if( inP!=NULL ) fclose( inP );
- return;
- }
-
- if( debug )
- {
- notify( "outTPrg = %x\n", outTPrg );
- notify( "outTMes = %x\n", outTMes );
- notify( "outPrg = %x\n", outPrg );
- notify( "outMes = %x\n", outMes );
- }
-
-
- if( outTPrg!=NULL )
- SetUpTitle( p, &v, outTPrg, line );
-
- if( outTMes!=NULL )
- SetUpTitle( p, &v, outTMes, line );
-
- if( SkipTOC( p, &v, 0 ) == 0 )
- {
- if( outTPrg!=NULL ) fclose( outTPrg );
- if( outTMes!=NULL ) fclose( outTMes );
- if( outPrg!=NULL ) fclose( outPrg );
- if( outMes!=NULL ) fclose( outMes );
- if( inP!=NULL ) fclose( inP );
- return;
- }
-
- if( MakeTOC( p, &v, line )==0 )
- {
- if( outTPrg!=NULL ) fclose( outTPrg );
- if( outTMes!=NULL ) fclose( outTMes );
- if( outPrg!=NULL ) fclose( outPrg );
- if( outMes!=NULL ) fclose( outMes );
- return;
- }
-
- fclose( inP );
-
- /* E N D O F P A S S 1 */
-
- notify("PASS2: '%s'...\n", digestName);
-
- if( (inP = fopen( digestName, "r" )) == NULL )
- {
- notify("Cannot open '%s',\n");
- return;
- }
-
- notify("Parsing...\n");
-
- if( findHeader( p, &v, line, 0 )==0 ) /* set-up header */
- return;
-
- if(debug)
- notify("Title found\n");
-
-
- if( outTPrg!=NULL )
- fputs("<CENTER><a href=index.html>Take me back to the INDEX, please.</a></CENTER><BR>"
- , outTPrg );
-
- if( outTMes!=NULL )
- fputs("<CENTER><a href=index.html>Take me back to the INDEX, please.</a></CENTER><BR>"
- , outTMes );
-
- if( SkipTOC( p, &v, 1 ) == 0 )
- {
- if( outTPrg!=NULL ) fclose( outTPrg );
- if( outTMes!=NULL ) fclose( outTMes );
- if( outPrg!=NULL ) fclose( outPrg );
- if( outMes!=NULL ) fclose( outMes );
- if( inP!=NULL ) fclose( inP );
- return;
- }
-
- if( DoMessages( p, &v, line )==0 )
- {
- if( outTPrg!=NULL ) fclose( outTPrg );
- if( outTMes!=NULL ) fclose( outTMes );
- if( outPrg!=NULL ) fclose( outPrg );
- if( outMes!=NULL ) fclose( outMes );
- if( inP!=NULL ) fclose( inP );
- return;
- }
-
- if(debug)
- notify("End of digest found...\n");
-
- if( outTPrg!=NULL )
- {
- WriteTrailer(outTPrg);
- fclose(outTPrg);
- }
-
- if( outTMes!=NULL )
- {
- WriteTrailer(outTMes);
- fclose(outTMes);
- }
-
- if( outPrg!=NULL )
- {
- WriteTrailer(outPrg);
- fclose(outPrg);
- }
-
- if( outMes!=NULL )
- {
- WriteTrailer(outMes);
- fclose(outMes);
- }
-
- notify("file closed.\n");
-
- #ifdef __THINK__
- SetUpAllFinderInfo( p, &v );
- #endif
- }
-
- int HandleArgs( ParsP p, int num_args, char *arg_strings[], char *digestName, char *parsName )
- {
- int i;
-
- strcpy( parsName, PARMS);
-
- if( num_args<2 )
- {
- notify("You can also start Digester from the command line.\n");
- notify("%s <filename> <b> <2> <3> <p> <f=digest.par>\n", arg_strings[0]);
- notify("b: use fancy buttons and icons.\n");
- notify("2: split up file in 2 parts\n");
- notify("3: split up file in 3 parts\n");
- notify("p: enable post reply.\n");
- notify("f=: alternative parameters file.\n");
- }
- else
- {
- p->Type=1;
- p->Buttons=0;
- p->Mail=0;
-
- strcpy( digestName, arg_strings[1] );
-
- for(i=2; i<num_args; i++)
- {
- switch( (arg_strings[i])[0] )
- {
- case 'b':
- p->Buttons=1;
- notify("Buttons on!\n");
- break;
-
- case '3':
- p->Type=2;
- notify("Split into 3 files!\n");
- break;
-
- case '2':
- p->Type=3;
- notify("Split into 2 files!\n");
- break;
-
- case 'p':
- p->Mail=1;
- notify("Enable post reply.\n");
- break;
-
- case 'f':
- if( ((arg_strings[i])[1]=='=') && (strlen(arg_strings[i])>2) )
- {
- strcpy( parsName, (arg_strings[i]+2) );
- }
- break;
-
- default:
- notify("Usage: %s <filename> <b> <2> <3> <p>\n", arg_strings[0]);
- notify("b: use fancy buttons and icons.\n");
- notify("2: split up file in 2 parts\n");
- notify("3: split up file in 3 parts\n");
- notify("p: enable post reply.\n");
- return(0);
- }
- }
- }
-
- return(1);
- }
-
- int GetSites( ParsP p )
- {
- char line[256];
- FILE *sitesP;
- int i;
-
- notify("\nGetting file of sites...\n");
-
- if((sitesP=fopen(p->sitesFile,"r"))==NULL)
- {
- notify("Can't open file sites file.\n");
- return(0);
- }
-
- p->nSites=atoi(fgets( line, 256, sitesP));
-
- if((p->sites=malloc(p->nSites*LINELENGTH))==NULL)
- {
- notify("Out of memory error...\n");
- return(0);
- }
-
- for( i=0; i<p->nSites; i++ )
- fgets( i*LINELENGTH+p->sites, LINELENGTH, sitesP);
-
- fclose(sitesP);
-
- return(1);
- }
-
- void convertCodes( char *line )
- {
- char tempLine[256];
- int l, i;
-
- tempLine[0]=0;
- l = 0;
- for(i=0; i<strlen(line); i++ )
- {
- if( line[i]=='\\' )
- {
- tempLine[l++] = line[i]-'a'+1;
- tempLine[l] = 0;
- }
- else
- {
- tempLine[l++] = line[i];
- tempLine[l] = 0;
- }
- }
- strcpy( line, tempLine );
- }
-
- void checkPar( char *line, char *token, char *par, int max )
- {
- char *bptr, *eptr;
-
- if( strncmp( line, token, strlen(token) )!=0 ) return;
-
- bptr = line+strlen(token);
-
- while( (*bptr!='"') && (*bptr!=0) ) bptr++; /* find first quote */
-
- if(*bptr==0)
- {
- notify("Failed to read parameter value of '%s'\n", token);
- return;
- }
-
- eptr=bptr+1;
-
- while( (*eptr!='"') && (*eptr!=0) ) eptr++; /* find second quote */
-
- if(*eptr==0)
- {
- notify("Failed to read parameter string of '%s'\n", token);
- return;
- }
-
- if((eptr-bptr)>max)
- {
- notify("Parameter string of '%s' too long\n", token);
- return;
- }
-
- *eptr=0; /* terminate the string */
-
- strcpy( par, bptr+1 ); /* copy the parameter string */
-
- if( debug )
- notify( "Parameter '%s': %s\n", token, par );
-
- convertCodes( par );
- }
-
- void checkParNum( char *line, char *token, int *par )
- {
- if( strncmp( line, token, strlen(token) )!=0 ) return;
-
- if( sscanf( line+strlen(token), "%d", par )!=1 )
- notify("Failed to get parameter '%s'.\n", token);
- else
- if( debug )
- notify("Parameter '%s': %d\n", token, *par );
- }
-
- void InitPars( ParsP p )
- {
- /* initialize all struct variables */
- strcpy( p->adLink, "" );
- strcpy( p->adImage, "" );
- p->adOn=0;
-
- strcpy( p->scriptPath, "/vdham-bin/" );
- strcpy( p->sitesFile, "sites.asc" );
- strcpy( p->imagePath, "" );
- strcpy( p->destPath, "" );
- strcpy( p->Ftype, "TEXT" );
- strcpy( p->Fcreator, "MOSS" );
-
- strcpy( p->DigestName, "infomac.txt" );
- strcpy( p->nameAll, "IM%d-%d.html" );
- strcpy( p->nameTOC, "IMt%d-%d.html" );
- strcpy( p->nameProg, "IMp%d-%d.html" );
- strcpy( p->nameMess, "IMm%d-%d.html" );
-
- strcpy( p->BegOfDigest, "Info-Mac Digest " );
- strcpy( p->Volume, "Volume" );
- strcpy( p->Issue, "Issue" );
- strcpy( p->Date, "" );
-
- strcpy( p->EndOfDigest, "End of Info-Mac Digest" );
- strcpy( p->BeginOfTopics, "Today's Topics:" );
- strcpy( p->EndOfTopics, "----------------------------------------------------------------------" );
- strcpy( p->EndOfMessage, "------------------------------\n" );
-
- strcpy( p->RootPath, "/info-mac/" );
- strcpy( p->BegOfFile, "[Archived as " );
- strcpy( p->EndOfFile, ";" );
-
- p->Type = 1;
- p->Buttons = 1;
- p->Mail = 1;
- p->Files = 1;
- p->URLs = 1;
- p->MURLs = 0;
-
- p->sites = NULL;
- p->nSites = 0;
-
- strcpy( p->mFrom, "From: ");
- strcpy( p->mTo, "To: ");
- strcpy( p->mDate, "Date: ");
- strcpy( p->mSubject, "Subject: ");
- }
-
- int GetParameters( ParsP p, char *name, int *promptP )
- {
- FILE *inP;
- char *cptr;
- char line[256];
-
- notify("Using parameter file: '%s'.\n", name );
-
- if( (inP = fopen(name, "r")) == NULL )
- {
- notify("Cannot open '%s', using default values\n", name);
- return(1);
- }
-
- while( !feof(inP) )
- {
- fgets( line, 256, inP );
-
- if( (cptr=strstr(line, "#")) != NULL ) /* mask comments */
- {
- *cptr=0;
- }
-
- if(strlen(line)>2)
- {
- checkPar( line, "ADLINK", p->adLink, 80 );
- checkPar( line, "ADIMAGE", p->adImage, 80 );
- checkParNum( line, "ADON", &(p->adOn));
-
- checkPar( line, "SCRIPT", p->scriptPath,80 );
- checkPar( line, "SITE", p->sitesFile,20 );
- checkPar( line, "PATH", p->destPath,80 );
- checkPar( line, "IMAGES", p->imagePath,80 );
- checkPar( line, "FTYPE", p->Ftype,6 );
- checkPar( line, "FCREAT", p->Fcreator, 6 );
-
- checkPar( line, "DIGNAM", p->DigestName,20);
- checkPar( line, "NAMA", p->nameAll,20);
- checkPar( line, "NAMT", p->nameTOC,20);
- checkPar( line, "NAMP", p->nameProg,20);
- checkPar( line, "NAMM", p->nameMess,20);
-
- checkPar( line, "BOD", p->BegOfDigest,80);
- checkPar( line, "VOL", p->Volume,80);
- checkPar( line, "ISS", p->Issue,80);
- checkPar( line, "DAT", p->Date,20);
-
- checkPar( line, "EOD", p->EndOfDigest,80);
- checkPar( line, "BOT", p->BeginOfTopics,80);
- checkPar( line, "EOT", p->EndOfTopics,80);
- checkPar( line, "EOM", p->EndOfMessage,80);
-
- checkPar( line, "RTD", p->RootPath,20);
- checkPar( line, "BOF", p->BegOfFile,40);
- checkPar( line, "EOF", p->EndOfFile,20);
-
- checkPar( line, "MDATE", p->mDate, 20 );
- checkPar( line, "MFROM", p->mFrom, 20 );
- checkPar( line, "MTO", p->mTo, 20 );
- checkPar( line, "MSUBJECT", p->mSubject, 20 );
-
-
- checkParNum( line, "TYP", &(p->Type));
- checkParNum( line, "BUT", &(p->Buttons));
- checkParNum( line, "MAI", &(p->Mail));
- checkParNum( line, "FIL", &(p->Files));
- checkParNum( line, "URL", &(p->URLs));
- checkParNum( line, "MURL", &(p->MURLs));
- checkParNum( line, "DEBUG", &debug);
- checkParNum( line, "PROMPT", promptP);
- }
- }
- return(0);
- }
-
- int main( int num_args, char *arg_strings[] )
- {
- char digestName[80], answer[80], parsName[80];
- char line[256];
- struct Pars p;
- int nopars;
- int prompt=1;
-
- InitPars( &p );
-
- if( HandleArgs( &p, num_args, arg_strings, digestName, parsName )==0 )
- return(1);
-
- nopars=GetParameters( &p, parsName, &prompt );
-
- if( p.Files )
- {
- if( GetSites( &p )==0 )
- return(1);
- }
-
-
- notify("\n\n*** D I G E S T E R ***\n\n");
- notify("by Andre' C. van der Ham\n\n");
- notify("This program parses info-mac digests you get by e-mail.\n");
- notify("Save the e-mail without headers and paragraph recognition (Eudora)\n");
- notify("Please, use one digest per file.\n");
- notify("Convert file to appropriate ascii format, for example: Mac->Unix\n\n");
- notify("The file can contain a number of digests.\n");
- notify("An HTML file is generated for each issue.\n");
- notify("Send bug reports, questions, etc... to:\n");
- notify("e-mail: A.C.vanderHam@ET.TUDelft.NL\n\n\n");
-
- if( num_args<2 )
- {
- #ifndef __THINK__
-
- notify("Input file (%s): ", p.DigestName);
- gets( digestName );
- if(strlen(digestName)<2)
- strcpy( digestName, p.DigestName);
- #else
- if( GetName( digestName )==0 ) return(1);
- #endif
-
- if(prompt)
- {
- notify("Use fancy buttons and icons (y/N): ");
- gets( answer );
-
- if( answer[0]=='y' )
- p.Buttons=1;
- else
- p.Buttons=0;
-
- notify("Include message selection button for reply (y/N): ");
- gets( answer );
-
- if( answer[0]=='y' )
- p.Mail=1;
- else
- p.Mail=0;
-
- notify("Split file into 3 separate files for topics, programs and messages (y/N): ");
- gets( answer );
-
- if( answer[0]=='y' )
- p.Type=2;
- else
- p.Type=1;
-
- notify("Split file into 2 separate files for programs and messages (y/N): ");
- gets( answer );
-
- if( answer[0]=='y' )
- p.Type=3;
- }
- }
-
- ParseOne( &p, digestName );
-
- notify("Thanks for using Digester.\nHave a nice day.\n");
- #ifdef __THINK__
- notify("Please press Return to continue.\n");
- #endif
-
- return(0);
- }